import java.util.Random;
import java.util.Scanner;

public class Demo8 {
    public static void main(String[] args) {
        Demo7 dm=new Demo7();
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入您要设置的账户:");
        String root=sc.nextLine();
        System.out.println("请输入你要设置的密码:");
        String pass=sc.nextLine();
        dm.setdatabase(root,pass);
        Random ran=new Random();
        int count=ran.nextInt(5)+1;
        System.out.println("你可登录的次数是:"+count);
        for (int i = 1; i <=count; i++) {
            System.out.println("请输入您的账号:");
            String root1=sc.nextLine();
            System.out.println("请输入您的密码:");
            String pass1=sc.nextLine();
            Boolean bl=dm.login(root1,pass1);
            if(bl==true){
                System.out.println("恭喜你,登录成功!");
                break;
            }else{
                if(i==count){
                    System.out.println("不好意思,登录失败,次数已用完请十分钟之后在尝试登录!");
                }else{
                    System.out.println("登录失败,你还有"+(count-i)+"次机会 !");
                }
            }
        }


    }
}
